package mysql

import (
	"gorm.io/gorm"
)

type Users struct {
	gorm.Model
	Tel      string `json:"tel" gorm:"type:char(11);not null;unique;comment:'手机号'"`
	Password string `json:"password" gorm:"type:char(32);not null;comment:'密码'"`
}

func (u *Users) Register() error {
	return DB.Debug().Model(&Users{}).Create(&u).Error
}

func Login(tel string) (users *Users, err error) {
	err = DB.Model(&Users{}).Where("tel=?", tel).Limit(1).Find(&users).Error
	return
}
